package com.tsxy.mall.mapper;

import com.tsxy.mall.entity.Address;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Repository
@Mapper
public interface AddressMapper {

    @Select({"select * from address where user_id = #{id}"})
    List<Address> getByUserId(Integer id);

    @Select({"select * from address where id = #{id}"})
    Address selectByPrimaryKey(Integer id);

    @Select({"select * from Address "})
    List<Address> getAll();

    @Insert({"<script>" +
            "insert into address (user_id,college ,major,detail,contact,phone) values " +
            "( #{userId},#{college},#{major},#{detail},#{contact},#{phone} )" +
            "</script>"})
    Integer insert(Address address);
}
